package view.ui
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.system.ApplicationDomain;
	import flash.utils.getDefinitionByName;
	
	import view.layer.BaseLayer;
	import view.ui.minimap.MiniMapContainer;
	import view.ui.minimap.UIMiniMap;
	
	/**
	 * 游戏界面UI 
	 * @author leo
	 * 
	 */	
	public class UIMain extends BaseLayer
	{
		public static const NAME :String = "mainUI";
		/**
		 * 小头像UI 
		 */		
		public var roleHeadUI :UIRoleHead;
		/**
		 * 左上角小地图UI，包括按钮 
		 */		
		public var miniMapUI :UIMiniMap;
		/**
		 * 底部UI 
		 */		
		public var bottomUI :UIBottom;
		/**
		 * 小地图 
		 */		
		public var miniMapContainer :MiniMapContainer;
		
		public function UIMain()
		{
			super();
			if(stage) init();
			else addEventListener(Event.ADDED_TO_STAGE,init);
		}
		
		
		/**
		 * 根据舞台大小调整ui位置 
		 */		
		public function resize():void
		{
			this.roleHeadUI.x = 0;
			this.roleHeadUI.y = 0;
			
			this.miniMapUI.x = stage.stageWidth - this.miniMapUI.width;
			
			this.bottomUI.x = stage.stageWidth - this.bottomUI.width;
			this.bottomUI.y = stage.stageHeight - this.bottomUI.height - 5;
			
			this.miniMapContainer.x = this.miniMapUI.x + 48;
			this.miniMapContainer.y = 33;
			
			UITaskTrack.I.x = stage.stageWidth - UITaskTrack.I.width + 5;
			UITaskTrack.I.y = this.miniMapUI.y + this.miniMapUI.height + 10;
		}
		/**
		 * 初始化游戏ui 
		 * @param event
		 * 
		 */		
		private function init(event :* = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,init);
			
			this.roleHeadUI = new UIRoleHead();
			this.addChild(this.roleHeadUI);
			
			this.miniMapUI = new UIMiniMap();
			this.miniMapUI.x = stage.stageWidth - this.miniMapUI.width;
			this.addChild(this.miniMapUI);
			
			this.bottomUI = new UIBottom();
			this.bottomUI.x = stage.stageWidth - this.bottomUI.width;
			this.bottomUI.y = stage.stageHeight - this.bottomUI.height - 5;
			this.addChild(this.bottomUI);
			
			this.miniMapContainer = new MiniMapContainer();
			this.miniMapContainer.x = this.miniMapUI.x + 48;
			this.miniMapContainer.y = 33;
			this.addChild(this.miniMapContainer);
			
			
			this.addChild(UITaskTrack.I);
			UITaskTrack.I.x = stage.stageWidth - UITaskTrack.I.width + 5;
			UITaskTrack.I.y = this.miniMapUI.y + this.miniMapUI.height + 10;
			
			
		}
	}
}